﻿using Android.Content;
using Android.Widget;
using System;

namespace BlackBoxForU.Feature
{
    class PasteBoard
    {
        public static String getClipBoardText(Context context)
        {
            ClipboardManager cm;
            cm = (ClipboardManager)context.GetSystemService(Context.ClipboardService);
            ClipData data = cm.PrimaryClip;
            if (data != null && data.ItemCount > 0)
            {
                String text = data.GetItemAt(0).Text.ToString();
                return text;
            }
            else
                return null;
        }
        public static void setClipBoardText(Context context, String text)
        {
            ClipboardManager cm;
            ClipData mClipData;
            cm = (ClipboardManager)context.GetSystemService(Context.ClipboardService);
            // 创建普通字符型ClipData
            mClipData = ClipData.NewPlainText("Label", text);
            // 将ClipData内容放到系统剪贴板里。
            cm.PrimaryClip = (mClipData);
            Toast.MakeText(context, "已复制到剪切板", ToastLength.Long).Show();
        }
    }
}